<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>with-&-debugger-&-use strict语句</title>
	</head>
	<body>
		<form>
			
		</form>
	</body>
	<script type="text/javascript">
		// "use strict"
		//same = 0;
		var arr = [1,2,3,4,5,6];
		var sum = 0;
		for(var i in arr){
			// sum += sum;debugger
			// console.log(arr[i]);
		}
		console.log(window)
		console.log(this)
		var hasStrictMode = (function(){"use strict";return this===undefined})();
		console.log(hasStrictMode)
		var noStrictMode = (function(){return this===undefined})();
		console.log(noStrictMode)
		var strictModeThis = (function(){return this})();
		console.log(strictModeThis)//此时非strictMode 的 this 指向的是全局变量 window
		
		
		
		/* 重点 eval()的优化 */
			var strictModeEval = (function(){
				"use strict";
				var str = "var x = 1;console.log(x);";
				eval(str);
				// console.log(x);
				/* 放开上句将会报错 */
			})();
			// console.log(x);
			var noStrictModeEval = (function(){
				var str = "var y = 1;console.log(y);";
				eval(str);
				console.log(y);
			})();		
			// console.log(y);
			
		/* 严格模式下函数声明中存在两个或多个同名参数将会产生语法错误 */
			var sameName = function(){
				// "use strict" //定义为标准模式时下行的函数参数区域将会报一个语法错误.
				var sameArgus2 = function(argu,argu){
					
				}
				sameArgus2()
			}
		
		/* 严格模式下在一对象下定义两个或多个属性时将会报一个语法错误 */
			var objSameAttr = function(){
				//"use strict" //此类情况,现IE11支持报错,chrome谷歌并未支持
				var obj = {
					"name":"lin1",
					"name":"lin2",
					name:"lin3",
					name:"lin4",
				};
				console.log(obj.name)//在非标准模式下得到的结果为：lin4
			}
			objSameAttr();
	</script>
	
</html>